Ext.define('ExtJs.view.message.module.MessageGrid',{
	extend:'Ext.grid.Panel',
	alias : 'widget.messageGrid',
	moduleId:0,
	initComponent:function(){
	
		
		var types =Ext.create('ExtJs.store.message.module.TypeStore',{storeId:'1'});
		var supplys =Ext.create('ExtJs.store.message.module.SupplyStore',{storeId:'1'});
		  
		
		var messageGridStore = Ext.create('ExtJs.store.message.module.MessageGridStore',{storeId:'govInfoModuleStore_'+this.moduleId});
		var govInfoModuleGrid = this;
		Ext.apply(this, {
			store:messageGridStore,
			tbar:[
				{text:this.moduleId,id:'add'+govInfoModuleGrid.moduleId},
					
					{
								xtype: 'combobox',
								fieldLabel: '类型',
								id:'type_id',
					    store: types,
					    queryMode: 'local',
					    displayField: 'name',
					    valueField: '___key_id',
					    labelWidth:40,
					    width:140
					},
					'-'
					,
					{
								xtype: 'combobox',
								fieldLabel: '供应商',
								id:'supply_id',
					    store: supplys,
					    queryMode: 'local',
					    displayField: 'name',
					    valueField: '___key_id',
					    labelWidth:50,
					    width:150
					},'-',
					{
				        xtype: 'datefield',
				        anchor: '100%',
				        fieldLabel: '开始时间',
				        id: 'from_date',
				        format:'Y-m-d',
				        maxValue: new Date() , // limited to the current date or prior
				        labelWidth:60,
					    			width:160
					}, '-',{
				        xtype: 'datefield',
				        anchor: '100%',
				        fieldLabel: '结束时间',
				        id: 'to_date',
				        format:'Y-m-d',
				    			maxValue: new Date(), 
				    			labelWidth:60,
							    width:160
				    },'-'
					,{
			        	xtype:'button',
			        	iconCls:'find',
			        	text:'搜索',
			        	id:'govInfoModuleSearchButton-'+govInfoModuleGrid.moduleId,
			        	handler:function(){
			        		//govInfoModuleGrid.store.load();
			        		//alert('govInfoModuleGrid_'+govInfoModuleGrid.moduleId);
			        		Ext.getCmp('govInfoModuleGrid_'+govInfoModuleGrid.moduleId).getStore().load();
			        	}
			        },'->'

					,{
			        	xtype:'button',
			        	iconCls:'table_save',
			        	text:'下载',
			        //	id:'govInfoModuleSearchButton-'+govInfoModuleGrid.moduleId,
			        	handler:function(){
			        		window.location='../test.xls'; 
			        		//govInfoModuleGrid.store.load();
			        		//alert('govInfoModuleGrid_'+govInfoModuleGrid.moduleId);
			        		//Ext.getCmp('govInfoModuleGrid_'+govInfoModuleGrid.moduleId).getStore().load();
			        	}
			        }
			],
			columns:[
				{header:'ID',dataIndex:'___key_id',hidden:true} ,
				{header:'时间',dataIndex:'createtime',xtype: 'datecolumn',   format:'Y-m-d'},
				{header:'入库单',dataIndex:'list_id'},
			
				{header:'单价',dataIndex:'price'},
				{header:'总量',dataIndex:'quantity'},
				{header:'供应商',dataIndex:'supply_id'},
				{header:'类型',dataIndex:'type_id'},
					{header:'金额',dataIndex:'cost'}
				
			],
			bbar: Ext.create('Ext.PagingToolbar', {
				id:'govInfoGridPagingToolbar_'+this.moduleId,
	            store: messageGridStore,
	            displayInfo: true,
	            displayMsg: '当前 {0} - {1} / {2}',
	            emptyMsg: "没有数据"
	        })
		});
		this.callParent(arguments);
	}
});